﻿using BCCommon;
using BCDto.Common.ErrorMessage;
using BCDto.TMS.SpecificServiceType;
using BCDto.TMS.TransferStation;
using BCDto.TMS.TransportSpecificServiceConfig;
using BCDto.TMS.TransportSpecificServiceConfigOverWrite;
using BCEntity.TMS.SpecificServiceType;
using BCEntity.TMS.TransportSpecificServiceConfig;
using BCEntity.TMS.TransportSpecificServiceConfigOverWrite;
using BCService.TMS.SpecificServiceType;
using BCService.TMS.TransferStation;
using BCService.TMS.TransportSpecificServiceConfig;
using BCService.TMS.TransportSpecificServiceConfigOverWrite;
using BCTMSRESTful.Configs;
using BCTMSRESTful.Controllers.Management;
using Microsoft.AspNetCore.Mvc;

namespace BCTMSRESTful.Controllers.Management.TMS.TransportSpecificServiceConfigOverWrite
{
    /// <summary>
    /// 运输特殊服务费配置接口
    /// </summary> 
    [ApiExplorerSettings(GroupName = "TMSAdmin")]
    [Route("api/v1/sim/[controller]")]
    public class TransportSpecificServiceConfigOverWriteController : ManagementBaseController
    {
        #region var
        private ITransportSpecificServiceConfigOverWriteService transportSpecificServiceConfigOverWriteService;

        public TransportSpecificServiceConfigOverWriteController(ITransportSpecificServiceConfigOverWriteService transportSpecificServiceConfigOverWriteService)
        {
            this.transportSpecificServiceConfigOverWriteService = transportSpecificServiceConfigOverWriteService;
        }
        #endregion

        #region POST 添加  
        /// <summary>
        /// 添加新运输特殊服务费配置纪录
        /// </summary>
        /// <param name="dto">运输特殊服务费配置数据模型</param>
        /// <returns></returns>
        [Log("添加新运输特殊服务费配置纪录")]
        [HttpPost]
        [ProducesResponseType(typeof(TransportSpecificServiceConfigOverWriteDto), 200)]
        public IActionResult Post([FromBody] TransportSpecificServiceConfigOverWriteRequestDto dto)
        {
            var a = transportSpecificServiceConfigOverWriteService.Add(dto, this.Admin);
            return Ok(a);
        }

        #endregion


        #region PUT 重写 修改   
        /// <summary>
        /// 修改重写运输特殊服务费配置纪录
        /// </summary>
        /// <param name="dto">重写运输特殊服务费配置数据模型</param>
        /// <returns></returns>
        [Log("重写修改运输特殊服务费配置纪录")]
        [HttpPut]
        [ProducesResponseType(typeof(TransportSpecificServiceConfigDto), 200)]
        public IActionResult Put([FromBody] TransportSpecificServiceConfigOverWritePutDto dto)
        {
            var a = Ok(transportSpecificServiceConfigOverWriteService.Update(dto, this.Admin));
            return a;
        }
        #endregion

        #region    重写 启用/禁用
        /// <summary>
        ///  启用/禁用重写运输特殊服务费配置纪录
        /// </summary>
        /// <param name="transportSpecificServiceConfigOverWriteId">特殊服务类型纪录重写id</param>
        /// <param name="enabled"></param>
        /// <returns></returns>
        [Log("启用/禁用重写运输特殊服务费配置纪录")] 
        [HttpPut("[action]/{transport_specific_service_config_overwrite_id}/{enabled}")]
        [ProducesResponseType(typeof(TransportSpecificServiceConfigViewDto), 200)]
        public IActionResult Enable(
            [FromRoute(Name = "transport_specific_service_config_overwrite_id")] long transportSpecificServiceConfigOverWriteId,
            [FromRoute(Name = "enable")] bool enabled)
        {
            return Ok(transportSpecificServiceConfigOverWriteService.UpdateEnable(this.Admin, transportSpecificServiceConfigOverWriteId, enabled));
        }
        #endregion

        #region Query 
        /// <summary>
        /// 查询运输特殊服务费配置
        /// </summary>
        /// <param name="vehicleTypeId">车辆类型Id</param>
        /// <param name="specificServiceType">特殊服务类型</param>
        /// <param name="serviceTitle">服务标题</param>
        /// <param name="provinceCode">省代码</param>
        /// <param name="cityCode">市代码</param>
        /// <param name="countyCode">区/县代码</param> 
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页大小</param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<TransportSpecificServiceConfigViewDto>), 200)]
        public IActionResult Query(
            [FromQuery(Name = "vehicle_type_id")] int? vehicleTypeId,
            [FromQuery(Name = "specific_service_type")] string specificServiceType,
            [FromQuery(Name = "service_title")] string serviceTitle,
            [FromQuery(Name = "province_code")] string provinceCode,
            [FromQuery(Name = "city_code")] string cityCode,
            [FromQuery(Name = "county_code")] string countyCode,
            [FromQuery(Name = "index")] int? pageIndex = 1,
            [FromQuery(Name = "size")] int? pageSize = 10)
        {
            var a = Ok(transportSpecificServiceConfigOverWriteService.GetList(Admin, vehicleTypeId, specificServiceType, serviceTitle, provinceCode, cityCode, countyCode, pageIndex.Value, pageSize.Value));
            return a;
        }
        #endregion


        #region QueryBase
        /// <summary>
        /// 查询区域运输特殊服务费基础配置
        /// </summary> 
        /// <param name="vehicleTypeId">车辆类型Id</param>
        /// <param name="specificServiceType">特殊服务类型</param>
        /// <param name="serviceTitle">服务标题</param> 
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页大小</param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<TransportSpecificServiceConfigDto>), 200)]
        public IActionResult QueryBase(
            [FromQuery(Name = "vehicle_type_id")] int? vehicleTypeId,
            [FromQuery(Name = "specific_service_type")] string specificServiceType,
            [FromQuery(Name = "service_title")] string serviceTitle,
            [FromQuery(Name = "index")] int? pageIndex = 1,
            [FromQuery(Name = "size")] int? pageSize = 10)
        {
            var a = Ok(transportSpecificServiceConfigOverWriteService.GetListBase(vehicleTypeId, specificServiceType, serviceTitle, pageIndex.Value, pageSize.Value));
            return a;
        }
        #endregion

    }
}
